//-----------------------------------------------------
// entity.cpp
//-----------------------------------------------------

/**
 * @file entity.cpp
 */

#include "entity.h"
#include "tools/vector.h"

namespace logic {

	CEntity::CEntity() : _visible(true) {}
	CEntity::~CEntity() {}

	void CEntity::update() {}

	bool CEntity::addObserver(Observer* newObserver)
	{
		_observers.push_back(newObserver);
		return true;
	}

	bool CEntity::removeObserver(Observer* oldObserver)
	{
		_observers.remove(oldObserver);
		return true;
	}

	void CEntity::emitPositionChanged()
	{
		std::list<CEntity::Observer*>::iterator it;
		it = _observers.begin();

		while (it != _observers.end())
		{
			(*it)->positionChanged(this, _pos);
			++it;
		}
	}

	void CEntity::emitVisibilityChanged()
	{
		std::list<CEntity::Observer*>::iterator it;
		it = _observers.begin();

		while (it != _observers.end())
		{
			(*it)->visibilityChanged(this, _visible);
			++it;
		}
	}

} // namespace logic